package com.example.chapter3.service.iml;

import com.example.chapter3.Dao.UserDao;
import com.example.chapter3.entity.User;
import com.example.chapter3.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceIml implements UserService {
    @Autowired
    private UserDao userDao;

    @Override
    public int addUser(User user) {
        return 0;
    }

    @Override
    public int updateUser(User user) {
        return 0;
    }

    @Override
    public int deleteUser(int id) {
        return 0;
    }

    @Override
    public User findUser(int id) {
        return null;
    }

    @Override
    public int register(User user) {
        return 0;
    }

    @Override
    public boolean login(String username, String password) {
        int count = userDao.findUserByName(username);
        if (count > 0) {
            // 假设这里有一个方法可以获取用户信息，你需要实现这个方法
            User user = userDao.findUserByNameForLogin(username); // 假设这个方法存在
            return user.getPassword().equals(password);
        }
        return false;
    }

    // ... 其他方法的实现
}